3.14 \(\int \frac {\sec ^2(x)}{a+b \csc (x)} \, dx\)

Optimal. Leaf size=65 \[ \frac {2 a b \tanh ^{-1}\left (\frac {a+b \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{\left (a^2-b^2\right )^{3/2}}-\frac {\sec (x) (b-a \sin (x))}{a^2-b^2} \]

[Out]

2*a*b*arctanh((a+b*tan(1/2*x))/(a^2-b^2)^(1/2))/(a^2-b^2)^(3/2)-sec(x)*(b-a*sin(x))/(a^2-b^2)

________________________________________________________________________________________

Rubi [A]  time = 0.14, antiderivative size = 65, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, integrand size = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.462, Rules used = {3872, 2866, 12, 2660, 618, 206} \[ \frac {2 a b \tanh ^{-1}\left (\frac {a+b \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{\left (a^2-b^2\right )^{3/2}}-\frac {\sec (x) (b-a \sin (x))}{a^2-b^2} \]

Antiderivative was successfully verified.

[In]

Int[Sec[x]^2/(a + b*Csc[x]),x]

[Out]

(2*a*b*ArcTanh[(a + b*Tan[x/2])/Sqrt[a^2 - b^2]])/(a^2 - b^2)^(3/2) - (Sec[x]*(b - a*Sin[x]))/(a^2 - b^2)

Rule 12

Int[(a_)*(u_), x_Symbol] :> Dist[a, Int[u, x], x] /; FreeQ[a, x] &&  !MatchQ[u, (b_)*(v_) /; FreeQ[b, x]]

Rule 206

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1*ArcTanh[(Rt[-b, 2]*x)/Rt[a, 2]])/(Rt[a, 2]*Rt[-b, 2]), x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 618

Int[((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Dist[-2, Subst[Int[1/Simp[b^2 - 4*a*c - x^2, x], x]
, x, b + 2*c*x], x] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 2660

Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x]}, Dis
t[(2*e)/d, Subst[Int[1/(a + 2*b*e*x + a*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] &&
 NeQ[a^2 - b^2, 0]

Rule 2866

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*sin[(e_.)
 + (f_.)*(x_)]), x_Symbol] :> Simp[((g*Cos[e + f*x])^(p + 1)*(a + b*Sin[e + f*x])^(m + 1)*(b*c - a*d - (a*c -
b*d)*Sin[e + f*x]))/(f*g*(a^2 - b^2)*(p + 1)), x] + Dist[1/(g^2*(a^2 - b^2)*(p + 1)), Int[(g*Cos[e + f*x])^(p
+ 2)*(a + b*Sin[e + f*x])^m*Simp[c*(a^2*(p + 2) - b^2*(m + p + 2)) + a*b*d*m + b*(a*c - b*d)*(m + p + 3)*Sin[e
 + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, g, m}, x] && NeQ[a^2 - b^2, 0] && LtQ[p, -1] && IntegerQ[2*m]

Rule 3872

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_.)*(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_))^(m_.), x_Symbol] :> Int[((g*C
os[e + f*x])^p*(b + a*Sin[e + f*x])^m)/Sin[e + f*x]^m, x] /; FreeQ[{a, b, e, f, g, p}, x] && IntegerQ[m]

Rubi steps

\begin {align*} \int \frac {\sec ^2(x)}{a+b \csc (x)} \, dx &=\int \frac {\sec (x) \tan (x)}{b+a \sin (x)} \, dx\\ &=-\frac {\sec (x) (b-a \sin (x))}{a^2-b^2}-\frac {\int \frac {a b}{b+a \sin (x)} \, dx}{a^2-b^2}\\ &=-\frac {\sec (x) (b-a \sin (x))}{a^2-b^2}-\frac {(a b) \int \frac {1}{b+a \sin (x)} \, dx}{a^2-b^2}\\ &=-\frac {\sec (x) (b-a \sin (x))}{a^2-b^2}-\frac {(2 a b) \operatorname {Subst}\left (\int \frac {1}{b+2 a x+b x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{a^2-b^2}\\ &=-\frac {\sec (x) (b-a \sin (x))}{a^2-b^2}+\frac {(4 a b) \operatorname {Subst}\left (\int \frac {1}{4 \left (a^2-b^2\right )-x^2} \, dx,x,2 a+2 b \tan \left (\frac {x}{2}\right )\right )}{a^2-b^2}\\ &=\frac {2 a b \tanh ^{-1}\left (\frac {a+b \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{\left (a^2-b^2\right )^{3/2}}-\frac {\sec (x) (b-a \sin (x))}{a^2-b^2}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]  time = 0.35, size = 97, normalized size = 1.49 \[ \frac {2 a b \tan ^{-1}\left (\frac {a+b \tan \left (\frac {x}{2}\right )}{\sqrt {b^2-a^2}}\right )}{\left (b^2-a^2\right )^{3/2}}+\sin \left (\frac {x}{2}\right ) \left (\frac {1}{(a-b) \left (\sin \left (\frac {x}{2}\right )+\cos \left (\frac {x}{2}\right )\right )}+\frac {1}{(a+b) \left (\cos \left (\frac {x}{2}\right )-\sin \left (\frac {x}{2}\right )\right )}\right ) \]

Antiderivative was successfully verified.

[In]

Integrate[Sec[x]^2/(a + b*Csc[x]),x]

[Out]

(2*a*b*ArcTan[(a + b*Tan[x/2])/Sqrt[-a^2 + b^2]])/(-a^2 + b^2)^(3/2) + Sin[x/2]*(1/((a + b)*(Cos[x/2] - Sin[x/
2])) + 1/((a - b)*(Cos[x/2] + Sin[x/2])))

________________________________________________________________________________________

fricas [A]  time = 0.67, size = 243, normalized size = 3.74 \[ \left [-\frac {\sqrt {a^{2} - b^{2}} a b \cos \relax (x) \log \left (-\frac {{\left (a^{2} - 2 \, b^{2}\right )} \cos \relax (x)^{2} + 2 \, a b \sin \relax (x) + a^{2} + b^{2} - 2 \, {\left (b \cos \relax (x) \sin \relax (x) + a \cos \relax (x)\right )} \sqrt {a^{2} - b^{2}}}{a^{2} \cos \relax (x)^{2} - 2 \, a b \sin \relax (x) - a^{2} - b^{2}}\right ) + 2 \, a^{2} b - 2 \, b^{3} - 2 \, {\left (a^{3} - a b^{2}\right )} \sin \relax (x)}{2 \, {\left (a^{4} - 2 \, a^{2} b^{2} + b^{4}\right )} \cos \relax (x)}, \frac {\sqrt {-a^{2} + b^{2}} a b \arctan \left (-\frac {\sqrt {-a^{2} + b^{2}} {\left (b \sin \relax (x) + a\right )}}{{\left (a^{2} - b^{2}\right )} \cos \relax (x)}\right ) \cos \relax (x) - a^{2} b + b^{3} + {\left (a^{3} - a b^{2}\right )} \sin \relax (x)}{{\left (a^{4} - 2 \, a^{2} b^{2} + b^{4}\right )} \cos \relax (x)}\right ] \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(x)^2/(a+b*csc(x)),x, algorithm="fricas")

[Out]

[-1/2*(sqrt(a^2 - b^2)*a*b*cos(x)*log(-((a^2 - 2*b^2)*cos(x)^2 + 2*a*b*sin(x) + a^2 + b^2 - 2*(b*cos(x)*sin(x)
 + a*cos(x))*sqrt(a^2 - b^2))/(a^2*cos(x)^2 - 2*a*b*sin(x) - a^2 - b^2)) + 2*a^2*b - 2*b^3 - 2*(a^3 - a*b^2)*s
in(x))/((a^4 - 2*a^2*b^2 + b^4)*cos(x)), (sqrt(-a^2 + b^2)*a*b*arctan(-sqrt(-a^2 + b^2)*(b*sin(x) + a)/((a^2 -
 b^2)*cos(x)))*cos(x) - a^2*b + b^3 + (a^3 - a*b^2)*sin(x))/((a^4 - 2*a^2*b^2 + b^4)*cos(x))]

________________________________________________________________________________________

giac [A]  time = 0.77, size = 95, normalized size = 1.46 \[ -\frac {2 \, {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\relax (b) + \arctan \left (\frac {b \tan \left (\frac {1}{2} \, x\right ) + a}{\sqrt {-a^{2} + b^{2}}}\right )\right )} a b}{{\left (a^{2} - b^{2}\right )} \sqrt {-a^{2} + b^{2}}} - \frac {2 \, {\left (a \tan \left (\frac {1}{2} \, x\right ) - b\right )}}{{\left (a^{2} - b^{2}\right )} {\left (\tan \left (\frac {1}{2} \, x\right )^{2} - 1\right )}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(x)^2/(a+b*csc(x)),x, algorithm="giac")

[Out]

-2*(pi*floor(1/2*x/pi + 1/2)*sgn(b) + arctan((b*tan(1/2*x) + a)/sqrt(-a^2 + b^2)))*a*b/((a^2 - b^2)*sqrt(-a^2
+ b^2)) - 2*(a*tan(1/2*x) - b)/((a^2 - b^2)*(tan(1/2*x)^2 - 1))

________________________________________________________________________________________

maple [A]  time = 0.44, size = 92, normalized size = 1.42 \[ -\frac {4}{\left (4 a -4 b \right ) \left (\tan \left (\frac {x}{2}\right )+1\right )}-\frac {2 a b \arctan \left (\frac {2 \tan \left (\frac {x}{2}\right ) b +2 a}{2 \sqrt {-a^{2}+b^{2}}}\right )}{\left (a -b \right ) \left (a +b \right ) \sqrt {-a^{2}+b^{2}}}-\frac {4}{\left (4 a +4 b \right ) \left (\tan \left (\frac {x}{2}\right )-1\right )} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sec(x)^2/(a+b*csc(x)),x)

[Out]

-4/(4*a-4*b)/(tan(1/2*x)+1)-2*a*b/(a-b)/(a+b)/(-a^2+b^2)^(1/2)*arctan(1/2*(2*tan(1/2*x)*b+2*a)/(-a^2+b^2)^(1/2
))-4/(4*a+4*b)/(tan(1/2*x)-1)

________________________________________________________________________________________

maxima [F(-2)]  time = 0.00, size = 0, normalized size = 0.00 \[ \text {Exception raised: ValueError} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(x)^2/(a+b*csc(x)),x, algorithm="maxima")

[Out]

Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(4*a^2-4*b^2>0)', see `assume?`
 for more details)Is 4*a^2-4*b^2 positive or negative?

________________________________________________________________________________________

mupad [B]  time = 0.40, size = 104, normalized size = 1.60 \[ \frac {\frac {2\,b}{a^2-b^2}-\frac {2\,a\,\mathrm {tan}\left (\frac {x}{2}\right )}{a^2-b^2}}{{\mathrm {tan}\left (\frac {x}{2}\right )}^2-1}+\frac {2\,a\,b\,\mathrm {atanh}\left (\frac {2\,a^3-2\,a\,b^2+2\,b\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (a^2-b^2\right )}{2\,{\left (a+b\right )}^{3/2}\,{\left (a-b\right )}^{3/2}}\right )}{{\left (a+b\right )}^{3/2}\,{\left (a-b\right )}^{3/2}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(1/(cos(x)^2*(a + b/sin(x))),x)

[Out]

((2*b)/(a^2 - b^2) - (2*a*tan(x/2))/(a^2 - b^2))/(tan(x/2)^2 - 1) + (2*a*b*atanh((2*a^3 - 2*a*b^2 + 2*b*tan(x/
2)*(a^2 - b^2))/(2*(a + b)^(3/2)*(a - b)^(3/2))))/((a + b)^(3/2)*(a - b)^(3/2))

________________________________________________________________________________________

sympy [F]  time = 0.00, size = 0, normalized size = 0.00 \[ \int \frac {\sec ^{2}{\relax (x )}}{a + b \csc {\relax (x )}}\, dx \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(x)**2/(a+b*csc(x)),x)

[Out]

Integral(sec(x)**2/(a + b*csc(x)), x)

________________________________________________________________________________________